﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace Quản_Lý_Thư_Viện
{
    class ThamsoDataAccess
    {
        private DataProvider _provider = new DataProvider();
        public ThamsoDataAccess()
        {
            _provider.connect();
        }
        public void updatethamso(ThamsoInfo info)
        {
            string updateCommand = "Update dbo.THAMSO set GIATRI = '" + info.Trigia + "' where MATHAMSO = '" + info.Mathamso + "'";
            _provider.executeNonQuery(updateCommand);
        }
        public DataTable laydsthamso()
        {
            return _provider.GetData("Select * from dbo.THAMSO");
        }
        public DataTable laysotienghsach()
        {
            return _provider.GetData("select giatri from thamso where thamso.mathamso = 'ts05'");
        }
        public DataTable laysotiengiahanthe()
        {
            return _provider.GetData("select giatri from thamso where thamso.mathamso = 'ts06'");
        }
        public void ghthe()
        {
            string updatecommand = ("update dbo.docgia set nghethan = dateadd(month," + frmGiaHan.sothangghthe + ",nghethan)  where (dbo.docgia.madg = '" + frmGiaHan.madg + "')");
            _provider.executeNonQuery(updatecommand);
        }

        public DataTable timdocgia()
        {
            return _provider.GetData("select dbo.docgia.hoten,dbo.loaithe.tenloaithe,dbo.docgia.nghethan from dbo.Docgia,dbo.loaithe where dbo.loaithe.maloaithe = dbo.docgia.maloaithe and dbo.docgia.madg = '" + frmGiaHan.madg + "'");
        }
        public DataTable timsach()
        {
            return _provider.GetData("select dbo.dausach.tensach,dbo.phieumuonsach.ngtraqd from dbo.dausach,dbo.sach,dbo.phieumuonsach,dbo.ct_pms where dbo.dausach.madausach = dbo.sach.madausach and dbo.sach.masach = dbo.ct_pms.masach and dbo.ct_pms.mapms = dbo.phieumuonsach.mapms and dbo.phieumuonsach.madg = '" + frmGiaHan.madg + "' and dbo.sach.masach = '" + frmGiaHan.masach + "'");
        }
        public DataTable timsachmp()
        {
            return _provider.GetData("select dbo.CT_PMS.MASACH, dbo.phieumuonsach.ngtraqd from  dbo.CT_PMS,dbo.PHIEUMUONSACH where CT_PMS.MAPMS= PHIEUMUONSACH.MAPMS and phieumuonsach.mapms = '" + frmGiaHan.mapm + "'");
        }
    }
}
